package GUI;


import java.util.ArrayList;

import javax.swing.JButton;

import Algorithms.Context;
import Algorithms.WidthStrategy;
import Cani.InLatime;
import Cani.Nod;
import Joc.Joc;
import Joc.JocStates;
import Operators.FarmerOperators;
import States.FarmerStates;
import Templates.Operator;
import Templates.State;
public class WidthAlgorithmCommand extends JButton implements Command {

	private static final long serialVersionUID = 1L;

	public WidthAlgorithmCommand() {
		super("Algoritm in Lungime");
	}

	public void execute() {
		SimulareDesenPanel.clearDesen();
		Joc j = Joc.getJocinstance();
		if (j.getState() == JocStates.CANI) {
			InLatime lat = new InLatime();
			Nod n = new Nod(0, 0);
			lat.adaugare_prim_nod(n);
			lat.rezolvare(n, 0);
			MassagePanel.writeMessagePanel("S-a aplicat algoritmul Lungime!" );
		}
		else if(j.getState()==JocStates.LCV){
			ArrayList<Operator<FarmerStates>> farmerOperators=FarmerOperators.returnOperators();
			State<FarmerStates> FarmerInitialState=FarmerStates.initalState();
			ArrayList<State<FarmerStates>> FarmerFinalState=FarmerStates.finalStates();
			String FarmerWidth="FarmerWidth.txt";
			Context<FarmerStates> f=new Context<FarmerStates>(new WidthStrategy<FarmerStates>());
			f.executeStrategy(FarmerInitialState,FarmerFinalState,farmerOperators,FarmerWidth);
			MassagePanel.writeMessagePanel("S-a aplicat algoritmul Lungime!" );
		}
		else if (j.getState() == JocStates.PUZZLE) {
			MassagePanel.writeMessagePanel("NU poate fi aplicat algoritmul Lungime!" );
		}
		
	}

}
